<?php
//这是告警模块

class Alarms extends spController
{
	function __construct(){ // 公用
		parent::__construct(); // 这是必须的
		$system = spClass("system");
		$sys=$system->findAll();
		$this->tpl_title = $sys[0][name];
		$this->email = $_SESSION["userinfo"]["mail"];
	}
	
	function alarm()
	{
		$alarm = spClass('alarm');
		$conditions= array
		(
			"user_id" => $_SESSION["userinfo"]["userid"],
		);
		$this->result = $alarm->spLinker()->spPager($this->spArgs('page', 1), 10)->findAll($conditions);
		$userid = $_SESSION["userinfo"]["userid"];
		$n=$alarm->spPager()->getPager();	
		$this->pager = $alarm->spPager()->getPager();	
		$this->display("member/main_alarm.html");
	}
	
	
	
	//告警历史
	function alarm_history()
	{
		$this->date1 = date("Y-m");	
		$alarm = spClass('alarm');
		$result=$alarm->n2_moth('0', $this->spArgs('page', 1), 10 );
		$this->list = $result['list'];
		$this->pager = $result['pagedata'];
		
		$site=spClass('site');
		$result=$site->a_site($this->spArgs('page', 1), 10 );
		$this->alist=$result['list'];
		$this->apager=$result['pagedata'];
		
		$this->display("member/Alarm_alarm_history.html");
	}
	function limit_alarm()
	{
		$data = $this->spArgs();
		$b = strtotime($data['btime'].'oo:oo:oo');
		$a = strtotime($data['atime'].'23:59:59');
		$alarm = spClass('alarm');
		$this->list = $alarm->nmoth($b,$a, $this->spArgs('page', 1), 10 );
		$this->pager = $alarm->pagedata;
		$this->btime=$data['btime'];
		$this->atime=$data['atime'];
		$this->display("member/main_nalarm.html");
	}
	//统计
	function statistics()
	{
		$site = spClass('site');
		//$conditions=array('userid'=>$_SESSION['userinfo']['userid']);
		//$this->list=$site->findAll($conditions);
		$result=$site->a_site($this->spArgs('page', 1), 10 );
		$this->list=$result['list'];
		$this->pager=$result['pagedata'];
		
		$site=spClass('site');
		$result=$site->a_site($this->spArgs('page', 1), 10 );
		$this->alist=$result['list'];
		$this->apager=$result['pagedata'];
		
		$this->display("member/Alarm_statistics.html");
	}
}	